package com.example.jetpackcomposebasic.todo.viewmodel.impl

import androidx.compose.runtime.mutableStateListOf
import androidx.lifecycle.ViewModel
import com.example.jetpackcomposebasic.todo.ToDoItem

/**
 * 基于MutableList实现的ViewModel
 */
class MutableListViewModel : ViewModel() {

    private val _toDoList: MutableList<ToDoItem> = mutableStateListOf()

    val toDoList: List<ToDoItem> = _toDoList

    fun addToDo(toDoItem: ToDoItem) {
        _toDoList.add(toDoItem)
    }

    fun removeToDo(toDoItem: ToDoItem) {
        _toDoList.remove(toDoItem)

    }
}